import axios from 'axios'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
export function request(config){
    // console.log(config);
    const instance=axios.create({
      baseURL:'http://127.0.0.1:8888/api/private/v1',
      timeout:5000,
    })
    //请求拦截器
    instance.interceptors.request.use(config=>{
      // console.log(config);
      config.headers.Authorization=window.sessionStorage.getItem('token')
      return config
    },err=>{
      // console.log(err);
    })

    //响应拦截
    instance.interceptors.response.use(res=>{
      // console.log(res);
      NProgress.done()
      return res.data
    },err=>{
      console.log(err);
    })
    //发送真正的网络请求
    return instance(config)
}

